import { fetchPost, fetchGet, $axios } from './axios.js';
export const getProjects = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/projects`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};

export const getProjectsById = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/queryProjectsById`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};

export const getBlog = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/articles`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};

export const getBlogById = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/queryArticleById`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};

export const getLink = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/links`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};

export const addDiscuss = (param) => {
  return new Promise((resolve) => {
    $axios.post(`/base-server/addDiscuss`,param).then((response) => {
      const data = response.data;
      if(data.success) {
        resolve(data)
      }else {
        $Message.error('请求错误')
      }
    }).catch( error => {
      console.log(error);
      $Message.error('请求错误')
    });
  });
};
